package com.tools.controller;

import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;


/**
 * @Author : ShangJY
 * @create 2023/11/17 8:46
 */
@RestController
@RequestMapping
public class PageController extends BaseController {


    @GetMapping(value = {"/", "index", "index.html"})
    public ModelAndView index() {
        ModelAndView view = jumpPage("index");
        return view;
    }

    @GetMapping(value = {"/view/{path}/{page}"})
    public ModelAndView allPage1(@PathVariable("path") String path, @PathVariable("page") String page) {
        return jumpPage(path + "/" + page);
    }

    @GetMapping(value = {"/console/{page}"})
    public ModelAndView allPage(@PathVariable("page") String page, Model model) {
        return jumpPage("console/" + page);
    }

    @GetMapping(value = {"/system/{page}"})
    public ModelAndView systemPage(@PathVariable("page") String page, Model model) {
        return jumpPage("system/" + page);
    }

    /**
     * Describe: 获取主页视图
     * Param: ModelAndView
     * Return: 主页视图
     */
    @GetMapping("console")
    public ModelAndView home() {
        return jumpPage("console/console");
    }

    /**
     * Describe:无权限页面
     * Return:返回403页面
     */
    @GetMapping("error/403")
    public ModelAndView noPermission() {
        return jumpPage("error/403");
    }

    /**
     * Describe:找不带页面
     * Return:返回404页面
     */
    @GetMapping("error/404")
    public ModelAndView notFound() {
        return jumpPage("error/404");
    }

    /**
     * Describe:异常处理页
     * Return:返回500界面
     */
    @GetMapping("error/500")
    public ModelAndView onException() {
        return jumpPage("error/500");
    }

}
